package com.yang.Inet.test;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class MyServerDemo {

	public static void main(String[] args) throws IOException {
		// 服务器
		ServerSocket ss = new ServerSocket(9000);
		// 客户端
		Socket s = ss.accept();

		InputStream in = s.getInputStream();

		byte[] buf = new byte[1024];

		int read = in.read(buf);

		String text = new String(buf, 0, read);

		PrintWriter out = new PrintWriter(s.getOutputStream(), true);
		System.out.println(text);

		out.println("你好!!" + s.getInetAddress().getHostName() + text);

		s.close();

		ss.close();

	}

}
